package com.ldapauth.openapi.rest;


import com.ldapauth.persistence.service.CommonTablesService;
import com.ldapauth.pojo.dto.CommonDeleteTableDTO;
import com.ldapauth.pojo.dto.CommonInsertTableDTO;
import com.ldapauth.pojo.dto.CommonSelectTableDTO;
import com.ldapauth.pojo.dto.CommonUpdateTableDTO;
import com.ldapauth.pojo.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * common 表基本表操作
 */
@Controller
@RequestMapping("/openapi/idm/commonTables")
public class RestCommonTablesController {

    @Autowired
    CommonTablesService commonTablesService;

    @RequestMapping(value = "/select",method = RequestMethod.POST)
    @ResponseBody
    public Result<List<Map<String,Object>>> select(@RequestBody CommonSelectTableDTO commonSelectTableDTO) {
        return Result.success(commonTablesService.select(commonSelectTableDTO));
    }

    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    @ResponseBody
    public Result<String> insert(@RequestBody CommonInsertTableDTO commonInsertTableDTO) {
        commonTablesService.insert(commonInsertTableDTO);
        return Result.success("成功");
    }

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    @ResponseBody
    public Result<String> update(@RequestBody CommonUpdateTableDTO commonUpdateTableDTO) {
        commonTablesService.update(commonUpdateTableDTO);
        return Result.success("成功");
    }

    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    @ResponseBody
    public Result<String> delete(@RequestBody CommonDeleteTableDTO commonDeleteTableDTO) {
        commonTablesService.delete(commonDeleteTableDTO);
        return Result.success("成功");
    }

}
